package com.asman.vr.constant

import com.asman.vr.utils.StringAppendUtils

object UrlConst {

    const val BASE_URL_RELEASE = "https://portal.asman.com.cn/"
    const val BASE_URL_TEST = "https://test.portal.asman.com.cn/"

    const val YYD_URL_SHORT = "http://url.cn/5i1j8Lb" //短信短链--应用宝

    // todo BuildConfig 还没有 BuildConfig.BASE_URL 先写死测试环境 
    //OSS需要的鉴权地址
    // const val OSS_STS = "${BuildConfig.BASE_URL}web/oss/get_sts"
    const val OSS_STS = "https://test.portal.asman.com.cn/web/oss/get_sts"

    const val SSQ_RETURN_URL = "https://www.asman.com.cn/" //上上签 returnUrl 地址

    // todo BuildConfig 还没有 BuildConfig.BASE_URL 先写死测试环境 
    //启动页切换Url--动态修改
    // var SplashBaseUrl = BuildConfig.BASE_URL
    var SplashBaseUrl = "https://test.portal.asman.com.cn/"

    // todo BuildConfig 还没有 BuildConfig.OPEN_LOG 先写死 true
    /**
     * 小牛师傅 接口host
     */
    fun WORKER_HOST_URL() =
        // when (if (BuildConfig.OPEN_LOG) SplashBaseUrl else BuildConfig.BASE_URL) {
        when (SplashBaseUrl) {
            BASE_URL_TEST -> {
                "https://test.admin.asman.com.cn/"
            }
            BASE_URL_RELEASE -> {
                "https://admin.asman.com.cn/"
            }
            else -> {
                "http://121.41.112.230:18081"
            }
        }

    // todo BuildConfig 还没有 BuildConfig.OPEN_LOG 先写死 true
    //web socket 地址
    fun SOCKET_URL() =
        // when (if (BuildConfig.OPEN_LOG) SplashBaseUrl else BuildConfig.BASE_URL) {
        when (SplashBaseUrl) {
            BASE_URL_TEST -> {
                "ws://test.portal.asman.com.cn"
            }
            BASE_URL_RELEASE -> {
                "wss://portal.asman.com.cn"
            }
            else -> {
                "ws://121.41.112.230:18080"
            }
        }

    // todo BuildConfig 还没有 BuildConfig.OPEN_LOG 先写死 true
    //3D换搭地址，根据BaseUrl 切换
    fun _3D_ROAM_URL() =
        // when (if (BuildConfig.OPEN_LOG) SplashBaseUrl else BuildConfig.BASE_URL) {
        when (SplashBaseUrl) {
            BASE_URL_TEST -> {
                "http://test.vr.asman.com.cn/vr.html"
            }
            BASE_URL_RELEASE -> {
                "https://vr.asman.com.cn/vr.html"
            }
            else -> {
                "http://dev.vr.asman.com.cn/vr.html"
            }
        }

    /**
     * 获取3D换搭全路径
     * @param schemeId 方案ID
     * @param vrType  1:ADC方案，2：3D MAX方案
     * @param workId  编辑过的方案ID
     * @param groupId  群聊ID
     * @param backUrl  是否有返回的页面--来自分享传false
     * @param token 登录token
     * @param roomId 通话房间ID
     */
    fun getFull3DRoamUrl(
        schemeId: Int? = null,
        vrType: Int? = null,
        workId: Long? = null,
        groupId: String? = null,
        backUrl: Boolean? = true,
        token: String? = null,
        roomId: Int? = null,
        tenant: String? = null
    ): String {
        return StringAppendUtils.builder()
            .append(_3D_ROAM_URL())
            .append(get3DParamsUrl(schemeId, vrType, workId, groupId, backUrl, token, roomId))
            .build()
    }

    fun get3DParamsUrl(
        schemeId: Int? = null,
        vrType: Int? = null,
        workId: Long? = null,
        groupId: String? = null,
        backUrl: Boolean? = true,
        token: String? = null,
        roomId: Int? = null
    ): String {
        val key =
            arrayOf<Any?>("schemeId", "vrType", "workId", "groupId", "backUrl", "token", "roomId")
        val value = arrayOf<Any?>(schemeId, vrType, workId, groupId, backUrl, token, roomId)
        //这里前面必须加上问好
        return "?" + StringAppendUtils.stringAppendKeyValue(key, value, "=", "&")
    }

}